package reflectPracticeDemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MethedPratice {

	public static void main(String[] args) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		Class<Student> c = Student.class;
		
		Constructor<Student> constructor = c.getConstructor();
		Student newInstance = constructor.newInstance();
		
//无参的方法
		Method methed1 = c.getMethod("methed1", null);
		methed1.invoke(newInstance, null);
		
//有参的方法
		Method methed2 = c.getMethod("methed2", String.class);
		methed2.invoke(newInstance, "陈奕迅");

	}

}
